home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / STANDARD / RFC / RFC1867.TXT < prev   
Encoding:
Text File  |  1995-11-09  |  27.5 KB  |  733 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13. Network Working Group                                           E. Nebel
  14.  
  15. Request For Comments: 1867                                   L. Masinter
  16.  
  17. Category: Experimental                                 Xerox Corporation
  18.  
  19.                                                            November 1995
  20.  
  21.  
  22.  
  23.  
  24.  
  25.                      Form-based File Upload in HTML
  26.  
  27.  
  28.  
  29. Status of this Memo
  30.  
  31.  
  32.  
  33.    This memo defines an Experimental Protocol for the Internet
  34.  
  35.    community.  This memo does not specify an Internet standard of any
  36.  
  37.    kind.  Discussion and suggestions for improvement are requested.
  38.  
  39.    Distribution of this memo is unlimited.
  40.  
  41.  
  42.  
  43. 1. Abstract
  44.  
  45.  
  46.  
  47.    Currently, HTML forms allow the producer of the form to request
  48.  
  49.    information from the user reading the form.  These forms have proven
  50.  
  51.    useful in a wide variety of applications in which input from the user
  52.  
  53.    is necessary.  However, this capability is limited because HTML forms
  54.  
  55.    don't provide a way to ask the user to submit files of data.  Service
  56.  
  57.    providers who need to get files from the user have had to implement
  58.  
  59.    custom user applications.  (Examples of these custom browsers have
  60.  
  61.    appeared on the www-talk mailing list.)  Since file-upload is a
  62.  
  63.    feature that will benefit many applications, this proposes an
  64.  
  65.    extension to HTML to allow information providers to express file
  66.  
  67.    upload requests uniformly, and a MIME compatible representation for
  68.  
  69.    file upload responses.  This also includes a description of a
  70.  
  71.    backward compatibility strategy that allows new servers to interact
  72.  
  73.    with the current HTML user agents.
  74.  
  75.  
  76.  
  77.    The proposal is independent of which version of HTML it becomes a
  78.  
  79.    part.
  80.  
  81.  
  82.  
  83. 2.  HTML forms with file submission
  84.  
  85.  
  86.  
  87.    The current HTML specification defines eight possible values for the
  88.  
  89.    attribute TYPE of an INPUT element: CHECKBOX, HIDDEN, IMAGE,
  90.  
  91.    PASSWORD, RADIO, RESET, SUBMIT, TEXT.
  92.  
  93.  
  94.  
  95.    In addition, it defines the default ENCTYPE attribute of the FORM
  96.  
  97.    element using the POST METHOD to have the default value
  98.  
  99.    "application/x-www-form-urlencoded".
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115. Nebel & Masinter              Experimental                      [Page 1]
  116.  
  117.  
  118.  
  119. RFC 1867             Form-based File Upload in HTML        November 1995
  120.  
  121.  
  122.  
  123.  
  124.  
  125.    This proposal makes two changes to HTML:
  126.  
  127.  
  128.  
  129.    1) Add a FILE option for the TYPE attribute of INPUT.
  130.  
  131.    2) Allow an ACCEPT attribute for INPUT tag, which is a list of
  132.  
  133.       media types or type patterns allowed for the input.
  134.  
  135.  
  136.  
  137.    In addition, it defines a new MIME media type, multipart/form-data,
  138.  
  139.    and specifies the behavior of HTML user agents when interpreting a
  140.  
  141.    form with ENCTYPE="multipart/form-data" and/or <INPUT type="file">
  142.  
  143.    tags.
  144.  
  145.  
  146.  
  147.    These changes might be considered independently, but are all
  148.  
  149.    necessary for reasonable file upload.
  150.  
  151.  
  152.  
  153.    The author of an HTML form who wants to request one or more files
  154.  
  155.    from a user would write (for example):
  156.  
  157.  
  158.  
  159.     <FORM ENCTYPE="multipart/form-data" ACTION="_URL_" METHOD=POST>
  160.  
  161.  
  162.  
  163.     File to process: <INPUT NAME="userfile1" TYPE="file">
  164.  
  165.  
  166.  
  167.     <INPUT TYPE="submit" VALUE="Send File">
  168.  
  169.  
  170.  
  171.     </FORM>
  172.  
  173.  
  174.  
  175.    The change to the HTML DTD is to add one item to the entity
  176.  
  177.    "InputType". In addition, it is proposed that the INPUT tag have an
  178.  
  179.    ACCEPT attribute, which is a list of comma-separated media types.
  180.  
  181.  
  182.  
  183.   ... (other elements) ...
  184.  
  185.  
  186.  
  187.   <!ENTITY % InputType "(TEXT | PASSWORD | CHECKBOX |
  188.  
  189.                          RADIO | SUBMIT | RESET |
  190.  
  191.                          IMAGE | HIDDEN | FILE )">
  192.  
  193.   <!ELEMENT INPUT - 0 EMPTY>
  194.  
  195.   <!ATTLIST INPUT
  196.  
  197.           TYPE %InputType TEXT
  198.  
  199.           NAME CDATA #IMPLIED  -- required for all but submit and reset
  200.  
  201.           VALUE CDATA #IMPLIED
  202.  
  203.           SRC %URI #IMPLIED  -- for image inputs --
  204.  
  205.           CHECKED (CHECKED) #IMPLIED
  206.  
  207.           SIZE CDATA #IMPLIED  --like NUMBERS,
  208.  
  209.                                   but delimited with comma, not space
  210.  
  211.           MAXLENGTH NUMBER #IMPLIED
  212.  
  213.           ALIGN (top|middle|bottom) #IMPLIED
  214.  
  215.           ACCEPT CDATA #IMPLIED --list of content types
  216.  
  217.           >
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227. Nebel & Masinter              Experimental                      [Page 2]
  228.  
  229.  
  230.  
  231. RFC 1867             Form-based File Upload in HTML        November 1995
  232.  
  233.  
  234.  
  235.  
  236.  
  237.   ... (other elements) ...
  238.  
  239.  
  240.  
  241. 3.  Suggested implementation
  242.  
  243.  
  244.  
  245.    While user agents that interpret HTML have wide leeway to choose the
  246.  
  247.    most appropriate mechanism for their context, this section suggests
  248.  
  249.    how one class of user agent, WWW browsers, might implement file
  250.  
  251.    upload.
  252.  
  253.  
  254.  
  255. 3.1 Display of FILE widget
  256.  
  257.  
  258.  
  259.    When a INPUT tag of type FILE is encountered, the browser might show
  260.  
  261.    a display of (previously selected) file names, and a "Browse" button
  262.  
  263.    or selection method. Selecting the "Browse" button would cause the
  264.  
  265.    browser to enter into a file selection mode appropriate for the
  266.  
  267.    platform. Window-based browsers might pop up a file selection window,
  268.  
  269.    for example. In such a file selection dialog, the user would have the
  270.  
  271.    option of replacing a current selection, adding a new file selection,
  272.  
  273.    etc. Browser implementors might choose let the list of file names be
  274.  
  275.    manually edited.
  276.  
  277.  
  278.  
  279.    If an ACCEPT attribute is present, the browser might constrain the
  280.  
  281.    file patterns prompted for to match those with the corresponding
  282.  
  283.    appropriate file extensions for the platform.
  284.  
  285.  
  286.  
  287. 3.2 Action on submit
  288.  
  289.  
  290.  
  291.    When the user completes the form, and selects the SUBMIT element, the
  292.  
  293.    browser should send the form data and the content of the selected
  294.  
  295.    files.  The encoding type application/x-www-form-urlencoded is
  296.  
  297.    inefficient for sending large quantities of binary data or text
  298.  
  299.    containing non-ASCII characters.  Thus, a new media type,
  300.  
  301.    multipart/form-data, is proposed as a way of efficiently sending the
  302.  
  303.    values associated with a filled-out form from client to server.
  304.  
  305.  
  306.  
  307. 3.3 use of multipart/form-data
  308.  
  309.  
  310.  
  311.    The definition of multipart/form-data is included in section 7.  A
  312.  
  313.    boundary is selected that does not occur in any of the data. (This
  314.  
  315.    selection is sometimes done probabilisticly.) Each field of the form
  316.  
  317.    is sent, in the order in which it occurs in the form, as a part of
  318.  
  319.    the multipart stream.  Each part identifies the INPUT name within the
  320.  
  321.    original HTML form. Each part should be labelled with an appropriate
  322.  
  323.    content-type if the media type is known (e.g., inferred from the file
  324.  
  325.    extension or operating system typing information) or as
  326.  
  327.    application/octet-stream.
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339. Nebel & Masinter              Experimental                      [Page 3]
  340.  
  341.  
  342.  
  343. RFC 1867             Form-based File Upload in HTML        November 1995
  344.  
  345.  
  346.  
  347.  
  348.  
  349.    If multiple files are selected, they should be transferred together
  350.  
  351.    using the multipart/mixed format.
  352.  
  353.  
  354.  
  355.    While the HTTP protocol can transport arbitrary BINARY data, the
  356.  
  357.    default for mail transport (e.g., if the ACTION is a "mailto:" URL)
  358.  
  359.    is the 7BIT encoding.  The value supplied for a part may need to be
  360.  
  361.    encoded and the "content-transfer-encoding" header supplied if the
  362.  
  363.    value does not conform to the default encoding.  [See section 5 of
  364.  
  365.    RFC 1521 for more details.]
  366.  
  367.  
  368.  
  369.    The original local file name may be supplied as well, either as a
  370.  
  371.    'filename' parameter either of the 'content-disposition: form-data'
  372.  
  373.    header or in the case of multiple files in a 'content-disposition:
  374.  
  375.    file' header of the subpart. The client application should make best
  376.  
  377.    effort to supply the file name; if the file name of the client's
  378.  
  379.    operating system is not in US-ASCII, the file name might be
  380.  
  381.    approximated or encoded using the method of RFC 1522.  This is a
  382.  
  383.    convenience for those cases where, for example, the uploaded files
  384.  
  385.    might contain references to each other, e.g., a TeX file and its .sty
  386.  
  387.    auxiliary style description.
  388.  
  389.  
  390.  
  391.    On the server end, the ACTION might point to a HTTP URL that
  392.  
  393.    implements the forms action via CGI. In such a case, the CGI program
  394.  
  395.    would note that the content-type is multipart/form-data, parse the
  396.  
  397.    various fields (checking for validity, writing the file data to local
  398.  
  399.    files for subsequent processing, etc.).
  400.  
  401.  
  402.  
  403. 3.4 Interpretation of other attributes
  404.  
  405.  
  406.  
  407.    The VALUE attribute might be used with <INPUT TYPE=file> tags for a
  408.  
  409.    default file name. This use is probably platform dependent.  It might
  410.  
  411.    be useful, however, in sequences of more than one transaction, e.g.,
  412.  
  413.    to avoid having the user prompted for the same file name over and
  414.  
  415.    over again.
  416.  
  417.  
  418.  
  419.    The SIZE attribute might be specified using SIZE=width,height, where
  420.  
  421.    width is some default for file name width, while height is the
  422.  
  423.    expected size showing the list of selected files.  For example, this
  424.  
  425.    would be useful for forms designers who expect to get several files
  426.  
  427.    and who would like to show a multiline file input field in the
  428.  
  429.    browser (with a "browse" button beside it, hopefully).  It would be
  430.  
  431.    useful to show a one line text field when no height is specified
  432.  
  433.    (when the forms designer expects one file, only) and to show a
  434.  
  435.    multiline text area with scrollbars when the height is greater than 1
  436.  
  437.    (when the forms designer expects multiple files).
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451. Nebel & Masinter              Experimental                      [Page 4]
  452.  
  453.  
  454.  
  455. RFC 1867             Form-based File Upload in HTML        November 1995
  456.  
  457.  
  458.  
  459.  
  460.  
  461. 4.  Backward compatibility issues
  462.  
  463.  
  464.  
  465.    While not necessary for successful adoption of an enhancement to the
  466.  
  467.    current WWW form mechanism, it is useful to also plan for a migration
  468.  
  469.    strategy: users with older browsers can still participate in file
  470.  
  471.    upload dialogs, using a helper application. Most current web browers,
  472.  
  473.    when given <INPUT TYPE=FILE>, will treat it as <INPUT TYPE=TEXT> and
  474.  
  475.    give the user a text box. The user can type in a file name into this
  476.  
  477.    text box. In addition, current browsers seem to ignore the ENCTYPE
  478.  
  479.    parameter in the <FORM> element, and always transmit the data as
  480.  
  481.    application/x-www-form-urlencoded.
  482.  
  483.  
  484.  
  485.    Thus, the server CGI might be written in a way that would note that
  486.  
  487.    the form data returned had content-type application/x-www-form-
  488.  
  489.    urlencoded instead of multipart/form-data, and know that the user was
  490.  
  491.    using a browser that didn't implement file upload.
  492.  
  493.  
  494.  
  495.    In this case, rather than replying with a "text/html" response, the
  496.  
  497.    CGI on the server could instead send back a data stream that a helper
  498.  
  499.    application might process instead; this would be a data stream of
  500.  
  501.    type "application/x-please-send-files", which contains:
  502.  
  503.  
  504.  
  505.    * The (fully qualified) URL to which the actual form data should
  506.  
  507.      be posted (terminated with CRLF)
  508.  
  509.    * The list of field names that were supposed to be file contents
  510.  
  511.      (space separated, terminated with CRLF)
  512.  
  513.    * The entire original application/x-www-form-urlencoded form data
  514.  
  515.      as originally sent from client to server.
  516.  
  517.  
  518.  
  519.    In this case, the browser needs to be configured to process
  520.  
  521.    application/x-please-send-files to launch a helper application.
  522.  
  523.  
  524.  
  525.    The helper would read the form data, note which fields contained
  526.  
  527.    'local file names' that needed to be replaced with their data
  528.  
  529.    content, might itself prompt the user for changing or adding to the
  530.  
  531.    list of files available, and then repackage the data & file contents
  532.  
  533.    in multipart/form-data for retransmission back to the server.
  534.  
  535.  
  536.  
  537.    The helper would generate the kind of data that a 'new' browser
  538.  
  539.    should actually have sent in the first place, with the intention that
  540.  
  541.    the URL to which it is sent corresponds to the original ACTION URL.
  542.  
  543.    The point of this is that the server can use the *same* CGI to
  544.  
  545.    implement the mechanism for dealing with both old and new browsers.
  546.  
  547.  
  548.  
  549.    The helper need not display the form data, but *should* ensure that
  550.  
  551.    the user actually be prompted about the suitability of sending the
  552.  
  553.    files requested (this is to avoid a security problem with malicious
  554.  
  555.    servers that ask for files that weren't actually promised by the
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563. Nebel & Masinter              Experimental                      [Page 5]
  564.  
  565.  
  566.  
  567. RFC 1867             Form-based File Upload in HTML        November 1995
  568.  
  569.  
  570.  
  571.  
  572.  
  573.    user.) It would be useful if the status of the transfer of the files
  574.  
  575.    involved could be displayed.
  576.  
  577.  
  578.  
  579. 5.  Other considerations
  580.  
  581.  
  582.  
  583. 5.1 Compression, encryption
  584.  
  585.  
  586.  
  587.    This scheme doesn't address the possible compression of files.  After
  588.  
  589.    some consideration, it seemed that the optimization issues of file
  590.  
  591.    compression were too complex to try to automatically have browsers
  592.  
  593.    decide that files should be compressed.  Many link-layer transport
  594.  
  595.    mechanisms (e.g., high-speed modems) perform data compression over
  596.  
  597.    the link, and optimizing for compression at this layer might not be
  598.  
  599.    appropriate. It might be possible for browsers to optionally produce
  600.  
  601.    a content-transfer-encoding of x-compress for file data, and for
  602.  
  603.    servers to decompress the data before processing, if desired; this
  604.  
  605.    was left out of the proposal, however.
  606.  
  607.  
  608.  
  609.    Similarly, the proposal does not contain a mechanism for encryption
  610.  
  611.    of the data; this should be handled by whatever other mechanisms are
  612.  
  613.    in place for secure transmission of data, whether via secure HTTP or
  614.  
  615.    mail.
  616.  
  617.  
  618.  
  619. 5.2 Deferred file transmission
  620.  
  621.  
  622.  
  623.    In some situations, it might be advisable to have the server validate
  624.  
  625.    various elements of the form data (user name, account, etc.)  before
  626.  
  627.    actually preparing to receive the data.  However, after some
  628.  
  629.    consideration, it seemed best to require that servers that wish to do
  630.  
  631.    this should implement this as a series of forms, where some of the
  632.  
  633.    data elements that were previously validated might be sent back to
  634.  
  635.    the client as 'hidden' fields, or by arranging the form so that the
  636.  
  637.    elements that need validation occur first.  This puts the onus of
  638.  
  639.    maintaining the state of a transaction only on those servers that
  640.  
  641.    wish to build a complex application, while allowing those cases that
  642.  
  643.    have simple input needs to be built simply.
  644.  
  645.  
  646.  
  647.    The HTTP protocol may require a content-length for the overall
  648.  
  649.    transmission. Even if it were not to do so, HTTP clients are
  650.  
  651.    encouraged to supply content-length for overall file input so that a
  652.  
  653.    busy server could detect if the proposed file data is too large to be
  654.  
  655.    processed reasonably and just return an error code and close the
  656.  
  657.    connection without waiting to process all of the incoming data.  Some
  658.  
  659.    current implementations of CGI require a content-length in all POST
  660.  
  661.    transactions.
  662.  
  663.  
  664.  
  665.    If the INPUT tag includes the attribute MAXLENGTH, the user agent
  666.  
  667.    should consider its value to represent the maximum Content-Length (in
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674.  
  675. Nebel & Masinter              Experimental                      [Page 6]
  676.  
  677.  
  678.  
  679. RFC 1867             Form-based File Upload in HTML        November 1995
  680.  
  681.  
  682.  
  683.  
  684.  
  685.    bytes) which the server will accept for transferred files.  In this
  686.  
  687.    way, servers can hint to the client how much space they have
  688.  
  689.    available for a file upload, before that upload takes place.  It is
  690.  
  691.    important to note, however, that this is only a hint, and the actual
  692.  
  693.    requirements of the server may change between form creation and file
  694.  
  695.    submission.
  696.  
  697.  
  698.  
  699.    In any case, a HTTP server may abort a file upload in the middle of
  700.  
  701.    the transaction if the file being received is too large.
  702.  
  703.  
  704.  
  705. 5.3 Other choices for return transmission of binary data
  706.  
  707.  
  708.  
  709.    Various people have suggested using new mime top-level type
  710.  
  711.    "aggregate", e.g., aggregate/mixed or a content-transfer-encoding of
  712.  
  713.    "packet" to express indeterminate-length binary data, rather than
  714.  
  715.    relying on the multipart-style boundaries.  While we are not opposed
  716.  
  717.    to doing so, this would require additional design and standardization
  718.  
  719.    work to get acceptance of "aggregate".  On the other hand, the
  720.  
  721.    'multipart' mechanisms are well established, simple to implement on
  722.  
  723.    both the sending client and receiving server, and as efficient as
  724.  
  725.    other methods of dealing with multiple combinations of binary data.
  726.  
  727.  
  728.  
  729. 5.4 Not overloading <INPUT>:
  730.  
  731.  
  732.  
  733.    Various people have wondered about the advisability of overloading
  734.  
  735.    'INPUT' for this function, rather than merely providing a different
  736.  
  737.    type of FORM element.  Among other considerations, the migration
  738.  
  739.    strategy which is allowed when using <INPUT> is important.  In
  740.  
  741.    addition, the <INPUT> field *is* already overloaded to contain most
  742.  
  743.    kinds of data input; rather than creating multiple kinds of <INPUT>
  744.  
  745.    tags, it seems most reasonable to enhance <INPUT>.  The 'type' of
  746.  
  747.    INPUT is not the content-type of what is returned, but rather the
  748.  
  749.    'widget-type'; i.e., it identifies the interaction style with the
  750.  
  751.    user.  The description here is carefully written to allow <INPUT
  752.  
  753.    TYPE=FILE> to work for text browsers or audio-markup.
  754.  
  755.  
  756.  
  757. 5.5 Default content-type of field data
  758.  
  759.  
  760.  
  761.    Many input fields in HTML are to be typed in. There has been some
  762.  
  763.    ambiguity as to how form data should be transmitted back to servers.
  764.  
  765.    Making the content-type of <INPUT> fields be text/plain clearly
  766.  
  767.    disambiguates that the client should properly encode the data before
  768.  
  769.    sending it back to the server with CRLFs.
  770.  
  771.  
  772.  
  773. 5.6 Allow form ACTION to be "mailto:"
  774.  
  775.  
  776.  
  777.    Independent of this proposal, it would be very useful for HTML
  778.  
  779.    interpreting user agents to allow a ACTION in a form to be a
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787. Nebel & Masinter              Experimental                      [Page 7]
  788.  
  789.  
  790.  
  791. RFC 1867             Form-based File Upload in HTML        November 1995
  792.  
  793.  
  794.  
  795.  
  796.  
  797.    "mailto:" URL. This seems like a good idea, with or without this
  798.  
  799.    proposal. Similarly, the ACTION for a HTML form which is received via
  800.  
  801.    mail should probably default to the "reply-to:" of the message.
  802.  
  803.    These two proposals would allow HTML forms to be served via HTTP
  804.  
  805.    servers but sent back via mail, or, alternatively, allow HTML forms
  806.  
  807.    to be sent by mail, filled out by HTML-aware mail recipients, and the
  808.  
  809.    results mailed back.
  810.  
  811.  
  812.  
  813. 5.7 Remote files with third-party transfer
  814.  
  815.  
  816.  
  817.    In some scenarios, the user operating the client software might want
  818.  
  819.    to specify a URL for remote data rather than a local file. In this
  820.  
  821.    case, is there a way to allow the browser to send to the client a
  822.  
  823.    pointer to the external data rather than the entire contents? This
  824.  
  825.    capability could be implemented, for example, by having the client
  826.  
  827.    send to the server data of type "message/external-body" with
  828.  
  829.    "access-type" set to, say, "uri", and the URL of the remote data in
  830.  
  831.    the body of the message.
  832.  
  833.  
  834.  
  835. 5.8 File transfer with ENCTYPE=x-www-form-urlencoded
  836.  
  837.  
  838.  
  839.    If a form contains <INPUT TYPE=file> elements but does not contain an
  840.  
  841.    ENCTYPE in the enclosing <FORM>, the behavior is not specified.  It
  842.  
  843.    is probably inappropriate to attempt to URN-encode large quantities
  844.  
  845.    of data to servers that don't expect it.
  846.  
  847.  
  848.  
  849. 5.9 CRLF used as line separator
  850.  
  851.  
  852.  
  853.    As with all MIME transmissions, CRLF is used as the separator for
  854.  
  855.    lines in a POST of the data in multipart/form-data.
  856.  
  857.  
  858.  
  859. 5.10 Relationship to multipart/related
  860.  
  861.  
  862.  
  863.    The MIMESGML group is proposing a new type called multipart/related.
  864.  
  865.    While it contains similar features to multipart/form-data, the use
  866.  
  867.    and application of form-data is different enough that form-data is
  868.  
  869.    being described separately.
  870.  
  871.  
  872.  
  873.    It might be possible at some point to encode the result of HTML forms
  874.  
  875.    (including files) in a multipart/related body part; this is not
  876.  
  877.    incompatible with this proposal.
  878.  
  879.  
  880.  
  881. 5.11 Non-ASCII field names
  882.  
  883.  
  884.  
  885.    Note that mime headers are generally required to consist only of 7-
  886.  
  887.    bit data in the US-ASCII character set. Hence field names should be
  888.  
  889.    encoded according to the prescriptions of RFC 1522 if they contain
  890.  
  891.    characters outside of that set. In HTML 2.0, the default character
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899. Nebel & Masinter              Experimental                      [Page 8]
  900.  
  901.  
  902.  
  903. RFC 1867             Form-based File Upload in HTML        November 1995
  904.  
  905.  
  906.  
  907.  
  908.  
  909.    set is ISO-8859-1, but non-ASCII characters in field names should be
  910.  
  911.    encoded.
  912.  
  913.  
  914.  
  915. 6. Examples
  916.  
  917.  
  918.  
  919.    Suppose the server supplies the following HTML:
  920.  
  921.  
  922.  
  923.      <FORM ACTION="http://server.dom/cgi/handle"
  924.  
  925.            ENCTYPE="multipart/form-data"
  926.  
  927.            METHOD=POST>
  928.  
  929.      What is your name? <INPUT TYPE=TEXT NAME=submitter>
  930.  
  931.      What files are you sending? <INPUT TYPE=FILE NAME=pics>
  932.  
  933.      </FORM>
  934.  
  935.  
  936.  
  937.    and the user types "Joe Blow" in the name field, and selects a text
  938.  
  939.    file "file1.txt" for the answer to 'What files are you sending?'
  940.  
  941.  
  942.  
  943.    The client might send back the following data:
  944.  
  945.  
  946.  
  947.         Content-type: multipart/form-data, boundary=AaB03x
  948.  
  949.  
  950.  
  951.         --AaB03x
  952.  
  953.         content-disposition: form-data; name="field1"
  954.  
  955.  
  956.  
  957.         Joe Blow
  958.  
  959.         --AaB03x
  960.  
  961.         content-disposition: form-data; name="pics"; filename="file1.txt"
  962.  
  963.         Content-Type: text/plain
  964.  
  965.  
  966.  
  967.          ... contents of file1.txt ...
  968.  
  969.         --AaB03x--
  970.  
  971.  
  972.  
  973.    If the user also indicated an image file "file2.gif" for the answer
  974.  
  975.    to 'What files are you sending?', the client might client might send
  976.  
  977.    back the following data:
  978.  
  979.  
  980.  
  981.         Content-type: multipart/form-data, boundary=AaB03x
  982.  
  983.  
  984.  
  985.         --AaB03x
  986.  
  987.         content-disposition: form-data; name="field1"
  988.  
  989.  
  990.  
  991.         Joe Blow
  992.  
  993.         --AaB03x
  994.  
  995.         content-disposition: form-data; name="pics"
  996.  
  997.         Content-type: multipart/mixed, boundary=BbC04y
  998.  
  999.  
  1000.  
  1001.         --BbC04y
  1002.  
  1003.         Content-disposition: attachment; filename="file1.txt"
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011. Nebel & Masinter              Experimental                      [Page 9]
  1012.  
  1013.  
  1014.  
  1015. RFC 1867             Form-based File Upload in HTML        November 1995
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.         Content-Type: text/plain
  1022.  
  1023.  
  1024.  
  1025.         ... contents of file1.txt ...
  1026.  
  1027.         --BbC04y
  1028.  
  1029.         Content-disposition: attachment; filename="file2.gif"
  1030.  
  1031.         Content-type: image/gif
  1032.  
  1033.         Content-Transfer-Encoding: binary
  1034.  
  1035.  
  1036.  
  1037.           ...contents of file2.gif...
  1038.  
  1039.         --BbC04y--
  1040.  
  1041.         --AaB03x--
  1042.  
  1043.  
  1044.  
  1045. 7. Registration of multipart/form-data
  1046.  
  1047.  
  1048.  
  1049.    The media-type multipart/form-data follows the rules of all multipart
  1050.  
  1051.    MIME data streams as outlined in RFC 1521. It is intended for use in
  1052.  
  1053.    returning the data that comes about from filling out a form. In a
  1054.  
  1055.    form (in HTML, although other applications may also use forms), there
  1056.  
  1057.    are a series of fields to be supplied by the user who fills out the
  1058.  
  1059.    form. Each field has a name. Within a given form, the names are
  1060.  
  1061.    unique.
  1062.  
  1063.  
  1064.  
  1065.    multipart/form-data contains a series of parts. Each part is expected
  1066.  
  1067.    to contain a content-disposition header where the value is "form-
  1068.  
  1069.    data" and a name attribute specifies the field name within the form,
  1070.  
  1071.    e.g., 'content-disposition: form-data; name="xxxxx"', where xxxxx is
  1072.  
  1073.    the field name corresponding to that field. Field names originally in
  1074.  
  1075.    non-ASCII character sets may be encoded using the method outlined in
  1076.  
  1077.    RFC 1522.
  1078.  
  1079.  
  1080.  
  1081.    As with all multipart MIME types, each part has an optional Content-
  1082.  
  1083.    Type which defaults to text/plain.  If the contents of a file are
  1084.  
  1085.    returned via filling out a form, then the file input is identified as
  1086.  
  1087.    application/octet-stream or the appropriate media type, if known.  If
  1088.  
  1089.    multiple files are to be returned as the result of a single form
  1090.  
  1091.    entry, they can be returned as multipart/mixed embedded within the
  1092.  
  1093.    multipart/form-data.
  1094.  
  1095.  
  1096.  
  1097.    Each part may be encoded and the "content-transfer-encoding" header
  1098.  
  1099.    supplied if the value of that part does not conform to the default
  1100.  
  1101.    encoding.
  1102.  
  1103.  
  1104.  
  1105.    File inputs may also identify the file name. The file name may be
  1106.  
  1107.    described using the 'filename' parameter of the "content-disposition"
  1108.  
  1109.    header. This is not required, but is strongly recommended in any case
  1110.  
  1111.    where the original filename is known. This is useful or necessary in
  1112.  
  1113.    many applications.
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123. Nebel & Masinter              Experimental                     [Page 10]
  1124.  
  1125.  
  1126.  
  1127. RFC 1867             Form-based File Upload in HTML        November 1995
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133. 8. Security Considerations
  1134.  
  1135.  
  1136.  
  1137.    It is important that a user agent not send any file that the user has
  1138.  
  1139.    not explicitly asked to be sent. Thus, HTML interpreting agents are
  1140.  
  1141.    expected to confirm any default file names that might be suggested
  1142.  
  1143.    with <INPUT TYPE=file VALUE="yyyy">.  Never have any hidden fields be
  1144.  
  1145.    able to specify any file.
  1146.  
  1147.  
  1148.  
  1149.    This proposal does not contain a mechanism for encryption of the
  1150.  
  1151.    data; this should be handled by whatever other mechanisms are in
  1152.  
  1153.    place for secure transmission of data, whether via secure HTTP, or by
  1154.  
  1155.    security provided by MOSS (described in RFC 1848).
  1156.  
  1157.  
  1158.  
  1159.    Once the file is uploaded, it is up to the receiver to process and
  1160.  
  1161.    store the file appropriately.
  1162.  
  1163.  
  1164.  
  1165. 9.  Conclusion
  1166.  
  1167.  
  1168.  
  1169.    The suggested implementation gives the client a lot of flexibility in
  1170.  
  1171.    the number and types of files it can send to the server, it gives the
  1172.  
  1173.    server control of the decision to accept the files, and it gives
  1174.  
  1175.    servers a chance to interact with browsers which do not support INPUT
  1176.  
  1177.    TYPE "file".
  1178.  
  1179.  
  1180.  
  1181.    The change to the HTML DTD is very simple, but very powerful.  It
  1182.  
  1183.    enables a much greater variety of services to be implemented via the
  1184.  
  1185.    World-Wide Web than is currently possible due to the lack of a file
  1186.  
  1187.    submission facility.  This would be an extremely valuable addition to
  1188.  
  1189.    the capabilities of the World-Wide Web.
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.  
  1196.  
  1197.  
  1198.  
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209.  
  1210.  
  1211.  
  1212.  
  1213.  
  1214.  
  1215.  
  1216.  
  1217.  
  1218.  
  1219.  
  1220.  
  1221.  
  1222.  
  1223.  
  1224.  
  1225.  
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235. Nebel & Masinter              Experimental                     [Page 11]
  1236.  
  1237.  
  1238.  
  1239. RFC 1867             Form-based File Upload in HTML        November 1995
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245. Authors' Addresses
  1246.  
  1247.  
  1248.  
  1249.    Larry Masinter
  1250.  
  1251.    Xerox Palo Alto Research Center
  1252.  
  1253.    3333 Coyote Hill Road
  1254.  
  1255.    Palo Alto, CA 94304
  1256.  
  1257.  
  1258.  
  1259.    Phone:  (415) 812-4365
  1260.  
  1261.    Fax:    (415) 812-4333
  1262.  
  1263.    EMail:   masinter@parc.xerox.com
  1264.  
  1265.  
  1266.  
  1267.  
  1268.  
  1269.    Ernesto Nebel
  1270.  
  1271.    XSoft, Xerox Corporation
  1272.  
  1273.    10875 Rancho Bernardo Road, Suite 200
  1274.  
  1275.    San Diego, CA 92127-2116
  1276.  
  1277.  
  1278.  
  1279.    Phone:  (619) 676-7817
  1280.  
  1281.    Fax:    (619) 676-7865
  1282.  
  1283.    EMail:   nebel@xsoft.sd.xerox.com
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326.  
  1327.  
  1328.  
  1329.  
  1330.  
  1331.  
  1332.  
  1333.  
  1334.  
  1335.  
  1336.  
  1337.  
  1338.  
  1339.  
  1340.  
  1341.  
  1342.  
  1343.  
  1344.  
  1345.  
  1346.  
  1347. Nebel & Masinter              Experimental                     [Page 12]
  1348.  
  1349.  
  1350.  
  1351. RFC 1867             Form-based File Upload in HTML        November 1995
  1352.  
  1353.  
  1354.  
  1355.  
  1356.  
  1357. A. Media type registration for multipart/form-data
  1358.  
  1359.  
  1360.  
  1361. Media Type name:
  1362.  
  1363.  multipart
  1364.  
  1365.  
  1366.  
  1367. Media subtype name:
  1368.  
  1369.  form-data
  1370.  
  1371.  
  1372.  
  1373. Required parameters:
  1374.  
  1375.  none
  1376.  
  1377.  
  1378.  
  1379. Optional parameters:
  1380.  
  1381.  none
  1382.  
  1383.  
  1384.  
  1385. Encoding considerations:
  1386.  
  1387.  No additional considerations other than as for other multipart types.
  1388.  
  1389.  
  1390.  
  1391. Published specification:
  1392.  
  1393.  RFC 1867
  1394.  
  1395.  
  1396.  
  1397. Security Considerations
  1398.  
  1399.  
  1400.  
  1401.   The multipart/form-data type introduces no new security
  1402.  
  1403.   considerations beyond what might occur with any of the enclosed
  1404.  
  1405.   parts.
  1406.  
  1407.  
  1408.  
  1409. References
  1410.  
  1411.  
  1412.  
  1413. [RFC 1521] MIME (Multipurpose Internet Mail Extensions) Part One:
  1414.  
  1415.            Mechanisms for Specifying and Describing the Format of
  1416.  
  1417.            Internet Message Bodies.  N. Borenstein & N. Freed.
  1418.  
  1419.            September 1993.
  1420.  
  1421.  
  1422.  
  1423. [RFC 1522] MIME (Multipurpose Internet Mail Extensions) Part Two:
  1424.  
  1425.            Message Header Extensions for Non-ASCII Text. K. Moore.
  1426.  
  1427.            September 1993.
  1428.  
  1429.  
  1430.  
  1431. [RFC 1806] Communicating Presentation Information in Internet
  1432.  
  1433.            Messages: The Content-Disposition Header. R. Troost & S.
  1434.  
  1435.            Dorner, June 1995.
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457.  
  1458.  
  1459. Nebel & Masinter              Experimental                     [Page 13]
  1460.  
  1461.  
  1462.  
  1463. .
  1464.  
  1465.